package com.hps.demo.controller;

import com.hps.demo.client.OrderClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * @author heps
 * @date 2019/11/23 17:01
 */
@RestController
@RequestMapping("/api/user")
public class UserController {


    private final OrderClient orderClient;

    public UserController(OrderClient orderClient) {
        this.orderClient = orderClient;
    }

    @GetMapping("/hello")
    public String hello() {
        return "Hello";
    }

    @GetMapping("/userOrder/{id}")
    public Map<String, Object> getUserOrder(@PathVariable("id") Long id) {
        Map<String, Object> result = new HashMap<>();
        result.put("id", id);
        result.put("name", "test");
        Map<String, Object> order = orderClient.getOrder(1L);
        result.put("orderInfo", order);
        return result;
    }
}
